[Bug]: Fix TypeError crash in tool.execute.after hooks when output.output is undefined#1723
Closed
RobertWsp wants to merge 1 commit intocode-yeongyu:devfrom
Closed
Conversation
Multiple tool.execute.after hooks crash with TypeError when MCP tools return responses where output.output is undefined/non-string. Add `if (typeof output.output !== 'string') return` guard to: - comment-checker/hook.ts - edit-error-recovery/hook.ts - task-resume-info/hook.ts This matches the existing pattern in tool-output-truncator.ts (line 42). Fixes crashes seen in v3.4.0 and v3.4.1 when using MCP server tools. Related: code-yeongyu#1720, code-yeongyu#1035
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Only adds type checks to prevent errors, no regressions introduced, aligns with criteria for safe changes.
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
marlon-costa-dc
pushed a commit
to marlon-costa-dc/oh-my-opencode
that referenced
this pull request
Feb 10, 2026
marlon-costa-dc
added a commit
to marlon-costa-dc/oh-my-opencode
that referenced
this pull request
Feb 10, 2026
Owner
|
Thank you for catching this TypeError issue! The fix has already been merged into dev via the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Multiple
tool.execute.afterhooks crash withTypeError: undefined is not an object (evaluating 'output.output.toLowerCase')when MCP tools return responses whereoutput.outputisundefinedor not a string.This affects v3.4.0 and was also present in v3.4.1 (which was yanked via #1720).
Error
Reproduction
Any MCP tool that returns a response where
output.outputisundefinedinstead of a string will trigger this crash. This commonly happens with:outputfieldRoot Cause
Three
tool.execute.afterhooks accessoutput.outputwithout checking if it's a string first:src/hooks/comment-checker/hook.ts(line 95):src/hooks/edit-error-recovery/hook.ts(line 47):src/hooks/task-resume-info/hook.ts(lines 24-25, 31):Fix
Added
if (typeof output.output !== 'string') returnas an early guard in all three affected hooks, matching the existing pattern already used insrc/hooks/tool-output-truncator.ts(line 42):This is the minimal, consistent fix — it follows the established convention in the codebase and gracefully handles the case where
output.outputisundefined,null, or any non-string type.Files Changed
src/hooks/comment-checker/hook.tsoutput.output.toLowerCase()src/hooks/edit-error-recovery/hook.tsoutput.output.toLowerCase()src/hooks/task-resume-info/hook.tsoutput.output.startsWith()Verification
bun run typecheck— passes clean (0 errors)bun run build— passes cleanRelated Issues
TypeErrorclassoutput.outputcrash (closed)Summary by cubic
Fixes a TypeError crash in tool.execute.after hooks when MCP tools return non-string or undefined output.output. Adds a simple guard so structured or metadata-only responses no longer break execution.
Written for commit 5a2075a. Summary will update on new commits.